home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / vol15n11.zip / SIMSPIN.VBA < prev    next >
Text File  |  1996-02-15  |  2KB  |  58 lines

  1. '*********************************************************************
  2. ' Public Sub SpinNumeric(ctl As Control, intIncrement As Integer, _
  3. '    intMin As Integer, intMax As Integer)
  4. '
  5. ' ctl - The control to spin
  6. ' intIncrement - The increment to use
  7. ' intMin - The minimum value to allow
  8. ' intMax - The maximum value to allow
  9. '*********************************************************************'
  10. Public Sub SpinNumeric(ctl As Control, intIncrement As Integer, _
  11.   intMin As Integer, intMax As Integer)
  12. On Error GoTo Err_SpinNumeric
  13.  
  14.    If (ctl + intIncrement) >= intMin Then    ' Check Min
  15.      If (ctl + intIncrement) <= intMax Then  ' Check Max
  16.        ctl = ctl + intIncrement              ' Spin it
  17.        DoEvents
  18.        Exit Sub
  19.      End If
  20.    End If
  21.  
  22.    DoCmd.Beep  ' Out of range
  23.    Exit Sub
  24.  
  25. Exit_SpinNumeric:
  26.    Exit Sub
  27.  
  28. Err_SpinNumeric:
  29.    MsgBox Err.Description
  30.    Resume Exit_SpinNumeric
  31.  
  32. End Sub
  33.  
  34. '*********************************************************************
  35. ' Public Sub SpinDate(ctl As Control, strInterval As String, _
  36. '   intIncrement As Integer)
  37. '
  38. ' ctl - The control to spin
  39. ' strInterval - The DateAdd interval to use
  40. ' intIncrement - The number of intervals to increment by
  41. '*********************************************************************'
  42. Public Sub SpinDate(ctl As Control, strInterval As String, _
  43.   intIncrement As Integer)
  44. On Error GoTo Err_SpinDate
  45.  
  46.    ctl = CVDate(ctl)       ' Make sure it's a date
  47.    ctl = DateAdd(strInterval, intIncrement, ctl) ' Spin it
  48.    DoEvents
  49.  
  50. Exit_SpinDate:
  51.    Exit Sub
  52.  
  53. Err_SpinDate:
  54.    MsgBox Err.Description
  55.    Resume Exit_SpinDate
  56.  
  57. End Sub
  58.